﻿/*
  Copyright © Alexander G. Bykin, Russia 2009-2010
  This source is subject to the Microsoft Public License (Ms-PL).
  Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
  All other rights reserved.
*/

namespace System.Windows.Controls
{
    using System.Collections.Generic;
    using System.Linq;

    public sealed class DataGridGroupItem
    {
        #region Public Properties

        public string DisplayName
        {
            get
            {
                var f = this.domainEntityFieldList.FirstOrDefault(r => r.PropertyPath == this.GroupDescriptor.PropertyPath);
                if (f == null) return this.GroupDescriptor.PropertyPath;
                          else return f.DisplayName;
            }
        }

        public GroupDescriptor GroupDescriptor { get; set; }

        #endregion

        #region Private Properties

        private IList<DomainEntityField> domainEntityFieldList { get; set; }

        #endregion

        #region Constructor

        public DataGridGroupItem(IList<DomainEntityField> DomainEntityFieldList)
        {
            this.domainEntityFieldList = DomainEntityFieldList;
        }

        #endregion
    }
}
